<template>
  <div>
    <!-- 头部信息 -->
    <div style="height: 60px;line-height: 60px;background-color: white;margin-bottom: 2px;display: flex" >
      <div style="width: 300px">
        <img src="@/assets/logo.png" alt="" style="width: 50px;position: relative;top: 10px;left: 20px">
        <span style="margin-left: 30px;font-size: 30px;" >图书管理系统</span>
      </div>
        <div style="flex: 1;text-align: right;padding-right: 40px;" >
          <el-dropdown size="medium " trigger="hover">
            <span class="el-dropdown-link" style="cursor: pointer" >
              <i class="el-icon-s-custom" style="color: #409dfe;padding-right: 10px;">
              </i>{{admin.username }}
              <i class="el-icon-arrow-down el-icon--right">
              </i>
            </span>
            <el-dropdown-menu slot="dropdown" style="margin-top: -5px">
              <el-dropdown-item>
                <div style="width: 50px;text-align: center" @click="logout">退出</div>
              </el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </div>
    </div>
    <!-- 侧边栏和主体   -->
    <div style="display: flex">
      <!--侧边导航-->
      <div  style="width: 200px; min-height:calc(100vh - 62px); overflow: hidden;margin-right: 2px;background-color: white">
        <el-menu :default-active="$route.path"  router class="el-menu-demo;">
          <el-menu-item index="/">
            <i class="el-icon-s-home" style="color: #409dfe"></i>
            <span>首页</span>
          </el-menu-item>
          <el-submenu index="/user">
            <template slot="title">
              <i class="el-icon-eleme" style="color: #409dfe"></i>
              <span>会员管理</span>
            </template>
            <el-menu-item index="/addUser">会员添加</el-menu-item>
            <el-menu-item index="/userList">会员列表</el-menu-item>
          </el-submenu>

          <el-submenu index="/admin">
            <template slot="title">
              <i class="el-icon-user" style="color: #409dfe"></i>
              <span>管理员管理</span>
            </template>
            <el-menu-item index="/addAdmin">管理员添加</el-menu-item>
            <el-menu-item index="/adminList">管理员列表</el-menu-item>
          </el-submenu>

          <el-submenu index="/category">
            <template slot="title">
              <i class="el-icon-s-operation" style="color: #409dfe"></i>
              <span>图书分类管理</span>
            </template>
            <el-menu-item index="/addCategory">分类添加</el-menu-item>
            <el-menu-item index="/categoryList">分类列表</el-menu-item>
          </el-submenu>

          <el-submenu index="/book">
            <template slot="title">
              <i class="el-icon-notebook-1" style="color: #409dfe"></i>
              <span>图书管理</span>
            </template>
            <el-menu-item index="/addBook">图书添加</el-menu-item>
            <el-menu-item index="/bookList">图书列表</el-menu-item>
          </el-submenu>

          <el-submenu index="/borrow">
            <template slot="title">
              <i class="el-icon-reading" style="color: #409dfe"></i>
              <span>借书管理</span>
            </template>
            <el-menu-item index="/addBorrow">我要借书</el-menu-item>
            <el-menu-item index="/borrowList">借书列表</el-menu-item>
          </el-submenu>

          <el-submenu index="/revert">
            <template slot="title">
              <i class="el-icon-document-checked" style="color: #409dfe"></i>
              <span>还书管理</span>
            </template>
            <el-menu-item index="/RevertList">还书列表</el-menu-item>
          </el-submenu>
        </el-menu>
      </div>
      <!--主体数据-->
      <div style="flex: 1;width: 0;background-color: white;padding: 10px">
        <router-view />
      </div>
    </div>
  </div>
</template>

<script>
import Cookies from "js-cookie";
export default {
  name: "Layout.vue",
  data(){
    return{
      admin:Cookies.get('admin') ? JSON.parse(Cookies.get('admin')) :{}
    }
  },
  methods:{
    logout(){
      //清楚浏览器数据
      Cookies.remove('admin')
      //返回登录页面
      this.$router.push('/login')
    }
  }
}
</script>

<style scoped>

</style>
